<?php
include_once '../header1.php';
?>
<link rel="stylesheet" href="../css/datepicker.css" type="text/css" />
    <link rel="stylesheet" media="screen" type="text/css" href="../css/layout.css" />
  	<script type="text/javascript" src="../js/jquery.js"></script>
	<script type="text/javascript" src="../js/datepicker.js"></script>
    <script type="text/javascript" src="../js/eye.js"></script>
    <script type="text/javascript" src="../js/utils.js"></script>
    <script type="text/javascript" src="../js/layout.js?ver=1.0.2"></script>
<script type="text/javascript">
function getHttpRequest()
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}
</script>
<script type="text/javascript">
function DeleteVerification(rownum,variables)
{
	var rownum=rownum;
	var id="Verifi";
var r=confirm("Are you sure to delete this?");
if(r==true)
{
document.getElementById(id).value=variables;
}
}
</script>
<script type="text/javascript">
function GetTBox(tbox,rows)
{
	var i;
	var box="groupcolumn"+tbox;
	for(i=1;i<=rows;i++)
	{
		var tb="groupcolumn"+i;
		var b="button"+i;
		if(tb!=box)
		{
		document.getElementById(tb).value="";
		document.getElementById(b).innerHTML="";
		}
	}
	
}
</script>
<script type="text/javascript">
function GetCol(val,name,rownum)
{
	var rownum=rownum;
	var xmlhttp; 
var b="button"+rownum;
var n=val+","+rownum+","+name;
if (val=="")
  {
  document.getElementById(b).innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById(b).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","butt.php?q="+n,true);
xmlhttp.send();
}
</script>
</head>
<body>
<?php

include_once ("../Login/databaseconnection.php");
if(!loggedin())
{
require_once ("../index.php");
}   
   else
   {
    date_default_timezone_set("Europe/Paris");
    $t_d=date("Y-m-d");
   $action="";
    if(!isset($_POST['gby'])&&!isset($_POST['groupback']))
  {
	   $_SESSION['sele_groupby']="";
	   $_SESSION['back_groupby']=0;	
 $_SESSION['Column_name']="";	
$_SESSION['gvals']=""; 
}	   
	   $action="";
  if(isset($_POST['gby']))
  {
	  $action="group";
	 $crvalues=$_POST['crval'];
	 $crvalu=explode(",",$crvalues);
	 $Column=$crvalu[0];
	 $rownum=$crvalu[1];
     $pri_keys=$_POST['pri'];
	 $prikeys=explode(",",$pri_keys);
	$School_Id=$prikeys[0];
	$Lab_Id=$prikeys[1];
    	 if(empty($_SESSION['sele_groupby']))
	  {
		 $_SESSION['sele_groupby']=$pri_keys.",".$Column;
	  }
	  else
	  {
		 $_SESSION['sele_groupby']=$_SESSION['sele_groupby']."_".$pri_keys.",".$Column;
	  } 
	  
$sele_groupby=explode("_",$_SESSION['sele_groupby']);

if($Column==1)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="School_Id";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",School_Id";
}
}
if($Column==2)
{
if(empty( $_SESSION['Column_name']))
{
$_SESSION['Column_name']="Lab_Id";
}
else
{
$_SESSION['Column_name']= $_SESSION['Column_name'].",Lab_Id";
}
}
if($Column==3)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Lab_Type";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Lab_Type";
}
}
if($Column==4)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Lab_Category";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Lab_Category";
}
}
if($Column==5)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Special_Project";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Special_Project";
}
}
if($Column==6)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Source_Of_Power";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Source_Of_Power";
}
}
if($Column==7)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Tp_Number";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Tp_Number";
}
}
 if($Column==8)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Account_Number";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Account_Number";
}
}
if($Column==9)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Date_of_commencement";
}
else
{
$_SESSION['Column_name']= $_SESSION['Column_name'].",Date_of_commencement";
}
}
if($Column==10)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Last_Updated_Date";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Last_Updated_Date";
}
}
if($Column==11)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Availability_Of_LAN";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Availability_Of_LAN";
}
}
if($Column==12)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="LAN_Supplier";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",LAN_Supplier";
}
}
if($Column==13)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Supplied_Date";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Supplied_Date";
}
}
if($Column==14)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Speed_Of_WAN";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Speed_Of_WAN";
}
}
if($Column==15)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="WAN_Connection_Type";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",WAN_Connection_Type";
}
}
if($Column==16)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Wired_Date";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Wired_Date";
}
}
if($Column==17)
{
if(empty( $_SESSION['Column_name']))
{
 $_SESSION['Column_name']="Internet_Facilities";
}
else
{
 $_SESSION['Column_name']= $_SESSION['Column_name'].",Internet_Facilities";
}
}

  $Column_names=explode(",", $_SESSION['Column_name']);
  $tot_cols=count($Column_names);
  $Exc_que="SELECT * FROM lab WHERE Lab_Id='".$Lab_Id."' AND School_Id='".$School_Id."'";
 $gro=mysql_query("SELECT * FROM lab WHERE Lab_Id='".$Lab_Id."' AND School_Id='".$School_Id."'");  
   $number_of_rows=mysql_num_rows($gro);
if($rowgro=mysql_fetch_array($gro))
{
$Col_name= $Column_names[$tot_cols-1];
if($rowgro[$Col_name]=="")
{
$_SESSION['value_empty']="Sorry,the column value is empty";
}
else
{
if(empty($_SESSION['gvals']))
{
$_SESSION['gvals']=$rowgro[$Col_name];
}
else
{
$_SESSION['gvals']=$_SESSION['gvals'].",".$rowgro[$Col_name];
}
}
}
	}  
   if(isset($_POST['groupback']))
  {
	  $sele_groupby=explode("_",$_SESSION['sele_groupby']);
	 $_SESSION['back_groupby']=$_SESSION['back_groupby']+1;
	 $gval=explode(",",$_SESSION['gvals']);
  $Column_names=explode(",",$_SESSION['Column_name']);
  $Columns="";
  $Vals="";
  for($b=0;$b<count($Column_names)-1;$b++)
  { 
   if(empty($Vals))
  {
  $Vals=$gval[$b];
  }
  else
  {
  $Vals=$Vals.",".$gval[$b];
  }
   if(empty($Columns))
  {
  $Columns=$Column_names[$b];
  }
  else
  {
  $Columns=$Columns.",".$Column_names[$b];
  }
  }
  $_SESSION['gvals']=$Vals;
$_SESSION['Column_name']=$Columns;
	
  $gval=explode(",",$_SESSION['gvals']);
  $Column_names=explode(",",$_SESSION['Column_name']);
    if($_SESSION['Access_Type']=="Administrator")
  {
   if($_SESSION['Column_name']=="")
  {
   $res_que="SELECT * FROM lab";
   $res_quenet="SELECT * FROM network";
  }
  else
  {
   $res_que="SELECT * FROM lab WHERE ";
   $res_quenet="SELECT * FROM network WHERE ";
   for($j=0;$j<count($Column_names);$j++)
  {
  $Col_name=$Column_names[$j];
   $res_que=$res_que.$Col_name."='".$gval[$j]."'";
   if($j!=(count($Column_names)-1))
  {
  $res_que=$res_que." AND ";
  }
  }
  }
    $resultgro=mysql_query($res_que);
	$Exc_que=$res_que;  
   $number_of_rows=mysql_num_rows($resultgro);
    }
 else if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
  {
  $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
   }
   if($_SESSION['Column_name']=="")
  {
   $res_que="SELECT * FROM lab WHERE School_Id='".$Own_School_Id."'";
   $res_quenet="SELECT * FROM network WHERE School_Id='".$Own_School_Id."'";
  }
else
  {
   $res_que="SELECT * FROM lab WHERE ";
   $res_quenet="SELECT * FROM network WHERE ";
   for($j=0;$j<count($Column_names);$j++)
  {
  $Col_name=$Column_names[$j];
    $res_que=$res_que.$Col_name."='".$gval[$j]."'";
   if($j!=(count($Column_names)-1))
  {
  $res_que=$res_que." AND ";
  }
  if($j==(count($Column_names)-1))
  {
  $res_que=$res_que." AND School_Id='".$Own_School_Id."'";
  }
  }
  }
     $resultgro=mysql_query($res_que);
	$Exc_que=$res_que;
   $number_of_rows=mysql_num_rows($resultgro);
     }
  }
    if(isset($_POST['dele']))
  {
   $action="delete";
   }
    if(!isset($_POST['dele']))
  {
  }
   ?>
<?php
include_once "../header2.php";
?>
<?php
include_once "topmenu.php";
?>
<div id="content">
	<div id="main">
	  <div id="bodyfield">
<br/>
<?php
if($action=="delete")
{
$dvari=$_POST['Verifi'];
if($dvari!="")
{
$vari=explode(",",$dvari);
$Lab_Id=$vari['1'];
$School_Id=$vari['0'];
}
if($dvari!="")
{
if($_SESSION['Access_Type']=="Administrator")
{
$resultdel=mysql_query("DELETE FROM lab WHERE Lab_Id='".$Lab_Id."' AND School_Id='".$School_Id."'");
if(mysql_affected_rows()!=0)
{
$_SESSION['del']="Successfully deleted!";
if($resultnet)
   {
		  while($rowtnet=mysql_fetch_array($resultnet))
		 {
		 	$Lab_Id=$rowtnet['Lab_Id'];
			$School_Id=$rowtnet['School_Id'];
		mysql_query("DELETE FROM network WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
		 }
		 }
		 	 if($resultres)
   {
		 while($rowres=mysql_fetch_array($resultres))
		 {
	    $Lab_Id=$rowres['Lab_Id'];
			$School_Id=$rowres['School_Id'];
		mysql_query("DELETE FROM resource_details WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
		 }
		 }
 	  if(mysql_num_rows(mysql_query("SELECT * FROM network WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'"))!=0)
	  {
$_SESSION['del']=$_SESSION['del']." ,unable to delete this record from network details!";
  }
  
  if(mysql_num_rows(mysql_query("SELECT * FROM resource_details WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'"))!=0)
	  {
 $_SESSION['del']=$_SESSION['del']." ,unable to delete this record from resource details!";
   }
}
if(mysql_affected_rows()==0)
{
$_SESSION['del']="Sorry unable to delete this!";
}
   if(!$delnet)
  {
 $_SESSION['error']=$_SESSION['error']." and unable to delete this record from Lab's network details!";
}
if(!$delres)
  {
$_SESSION['error']=$_SESSION['error']." and unable to delete this Lab's resources!";  
  }
}
else if($_SESSION['Access_Type']=="Teacher in Charge")
   {
$result=mysql_query("SELECT * FROM lab WHERE Lab_Id='".$Lab_Id."' AND School_Id='".$School_Id."'");
$resultnet=mysql_query("SELECT * FROM network WHERE Lab_Id='".$Lab_Id."' AND School_Id='".$School_Id."'");
$resultres=mysql_query("SELECT * FROM resource_details WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
	$Accessed_By=$_SESSION['NIC_Number'];
	if($row=mysql_fetch_array($result))
   {
   $Lab_Type=$row['Lab_Type'];
  $Lab_Id=$row['Lab_Id'];
   $School_Id=$row['School_Id'];
 $Source_Of_Power=$row['Source_Of_Power'];
      	$Tp_Number=$row['Tp_Number'];
      	$Special_Project=$row['Special_Project'];
      	$Lab_Category=$row['Lab_Category'];
    $Account_Number=$row['Account_Number'];
    $Date_of_commencement=$row['Date_of_commencement'];   
	$Last_Updated_Date=$row['Last_Updated_Date'];  
   }
   if($resultnet)
		 {
   while($rownet=mysql_fetch_array($resultnet))
   {
   if(empty($Availability_Of_LAN))
   {
   $Availability_Of_LAN=$rownet['Availability_Of_LAN'];
   }
   else
   {
      $Availability_Of_LAN=$Availability_Of_LAN.",".$rownet['Availability_Of_LAN'];
   }
   if(empty($LAN_Supplier))
   {
   $LAN_Supplier=$rownet['LAN_Supplier'];
   }
   else
   {
      $LAN_Supplier=$LAN_Supplier.",".$rownet['LAN_Supplier'];
   }
   if(empty($Supplied_Date))
   {
   $Supplied_Date=$rownet['Supplied_Date'];
   }
   else
   {
      $Supplied_Date=$Supplied_Date.",".$rownet['Supplied_Date'];
   }
    if(empty($Speed_Of_WAN))
   {
   $Speed_Of_WAN=$rownet['Speed_Of_WAN'];
   }
   else
   {
      $Speed_Of_WAN=$Speed_Of_WAN.",".$rownet['Speed_Of_WAN'];
   }
    if(empty($WAN_Connection_Type))
   {
   $WAN_Connection_Type=$rownet['WAN_Connection_Type'];
   }
   else
   {
      $WAN_Connection_Type=$WAN_Connection_Type.",".$rownet['WAN_Connection_Type'];
   }
    if(empty($Wired_Date))
   {
   $Wired_Date=$rownet['Wired_Date'];
   }
   else
   {
      $Wired_Date=$Wired_Date.",".$rownet['Wired_Date'];
   }
     if(empty($Internet_Facilities))
   {
   $Internet_Facilities=$rownet['Internet_Facilities'];
   }
   else
   {
      $Internet_Facilities=$Internet_Facilities.",".$rownet['Internet_Facilities'];
   }
	     }
		 }
		 if($resultres)
		 {
	 while($rowres=mysql_fetch_array($resultres))
   {
   if(empty($Resource_Id))
   {
   $Resource_Id=$rownet['Resource_Id'];
   }
   else
   {
      $Resource_Id=$Resource_Id.",".$rownet['Resource_Id'];
   }
   if(empty($Serial_Number))
   {
   $Serial_Number=$rownet['Serial_Number'];
   }
   else
   {
      $Serial_Number=$Serial_Number.",".$rownet['Serial_Number'];
   }
   if(empty($Functioning))
   {
   $Functioning=$rownet['Functioning'];
   }
   else
   {
      $Functioning=$Functioning.",".$rownet['Functioning'];
   }
   if(empty($Brand_Name))
   {
   $Brand_Name=$rownet['Brand_Name'];
   }
   else
   {
      $Brand_Name=$Brand_Name.",".$rownet['Brand_Name'];
   }
if(empty($Date_Of_Supplied))
   {
   $Date_Of_Supplied=$rownet['Date_Of_Supplied'];
   }
   else
   {
      $Date_Of_Supplied=$Date_Of_Supplied.",".$rownet['Date_Of_Supplied'];
   }
   if(empty($Name_Of_Supplier))
   {
   $Name_Of_Supplier=$rownet['Name_Of_Supplier'];
   }
   else
   {
      $Name_Of_Supplier=$Name_Of_Supplier.",".$rownet['Name_Of_Supplier'];
   }
   if(empty($Funding_Source))
   {
   $Funding_Source=$rownet['Funding_Source'];
   }
   else
   {
      $Funding_Source=$Funding_Source.",".$rownet['Funding_Source'];
   }   
     }
	 }
$sql=mysql_query("INSERT INTO deleted_lab(Special_Project,Lab_Category,Lab_Id,Lab_Type,School_Id,Source_Of_Power,Tp_Number,Account_Number,Date_of_commencement,Deleted_date,Accessed_By,Last_Updated_Date,Availability_Of_LAN,LAN_Supplier,Speed_Of_WAN,Supplied_Date,WAN_Connection_Type,Wired_Date,Internet_Facilities,Serial_Number,Functioning,Brand_Name,Date_Of_Supplied,Name_Of_Supplier,Funding_Source) VALUES('$Special_Project','$Lab_Category','$Lab_Id','$Lab_Type','$School_Id','$Source_Of_Power','$Tp_Number','$Account_Number','$Date_of_commencement','$t_d','$Accessed_By','$Last_Updated_Date','$Availability_Of_LAN','$LAN_Supplier','$Speed_Of_WAN','$Supplied_Date','$WAN_Connection_Type','$Wired_Date','$Internet_Facilities','$Serial_Number','$Functioning','$Brand_Name','$Date_Of_Supplied','$Name_Of_Supplier','$Funding_Source')");
if($sql){
	$del==mysql_query("DELETE FROM lab WHERE Lab_Id='".$Lab_Id."' AND School_Id='".$School_Id."'");
	if(mysql_affected_rows()!=0)
  {
$_SESSION['del']="This record is successfully deleted!";
if($resultnet)
   {
		  while($rowtnet=mysql_fetch_array($resultnet))
		 {
		 	$Lab_Id=$rowtnet['Lab_Id'];
			$School_Id=$rowtnet['School_Id'];
		mysql_query("DELETE FROM network WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
		 }
		 }
		 	 if($resultres)
   {
		 while($rowres=mysql_fetch_array($resultres))
		 {
	    $Lab_Id=$rowres['Lab_Id'];
			$School_Id=$rowres['School_Id'];
		mysql_query("DELETE FROM resource_details WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
		 }
		 }
 		  if(mysql_num_rows(mysql_query("SELECT * FROM network WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'"))!=0)
	  {
$_SESSION['del']=$_SESSION['del']." ,unable to delete this record from network details!";
  }
  
  if(mysql_num_rows(mysql_query("SELECT * FROM resource_details WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'"))!=0)
	  {
 $_SESSION['del']=$_SESSION['del']." ,unable to delete this record from resource details!";
   }
 }
  if(mysql_affected_rows()==0)
  {
 $_SESSION['del']="Sorry unable to delete this lab's basic record from Lab's record!";
 mysql_query("DELETE FROM deleted_lab WHERE Lab_Id='".$Lab_Id."' AND School_Id='".$School_Id."' AND Deleted_Date='".$t_d."' AND Resource_Id='".$Resource_Id."' AND Serial_Number='".$Serial_Number."'");
   if(!$delnet)
  {
  if($_SESSION['del']=="This record is successfully deleted!")
  {
   $_SESSION['errornet']='<img src="../images/alert.jpg" width="12" height="12"/>';
   $_SESSION['errornet']=$_SESSION['errornet']."Sorry unable to delete this record from Lab's network details!";
   }
    if($_SESSION['del']=="Sorry unable to delete this lab's basic record from Lab's record!")
  {
   $_SESSION['errornet']="And unable to delete this record from Lab's network details!";
   }
}
 if(!$delres)
  {
$_SESSION['errornet']=$_SESSION['errornet']." and unable to delete this Lab's resources!";  
  }
  }
  }
    if(!$sql)
{
 $_SESSION['del']="Sorry unable to delete this record!";
 }
}
}
}
?>
<form  action="#" method="POST">
<?php
echo "<input type='hidden' size='1' id='Verifi' name='Verifi'/>";
echo '<br/>';
 
if($_GET['action']=="edit"&&$action!="delete"&&$action!="group"&&!isset($_POST['groupback'])&&$_SESSION['Access_Type']!="Teacher")
	{
$School_Id=$_GET['School_Id'];
$Lab_Id=$_GET['Lab_Id'];
$result=mysql_query("SELECT * FROM lab WHERE Lab_Id='".$Lab_Id."' AND School_Id='".$School_Id."'");
$resultnetwork=mysql_query("SELECT * FROM network WHERE Lab_Id='".$Lab_Id."' AND School_Id='".$School_Id."'");
if($result)
   {
$qucol="SHOW COLUMNS FROM lab";
$resultcol=mysql_query($qucol);
$totcol=mysql_num_rows($resultcol);
while($rowcolu=mysql_fetch_row($resultcol))
{
if($rowcolu[0]!="Last_Updated_Date")
{
if(empty($colnamearray))
{
$colnamearray=$rowcolu[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolu[0];
}
}
}
$qucolnet="SHOW COLUMNS FROM network";
$resultcolnet=mysql_query($qucolnet);
$totcolnet=mysql_num_rows($resultcolnet);
while($rowcolunet=mysql_fetch_row($resultcolnet))
{
if($rowcolunet[0]!="School_Id"&&$rowcolunet[0]!="Lab_Id")
{
if(empty($colnamearray))
{
$colnamearray=$rowcolunet[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolunet[0];
}
}
}
 $cnamearray=explode(',',$colnamearray);
    if(!isset($_POST['Go']))
	 {
	 echo '<table class="tablefontv">';
	if($row=mysql_fetch_array($result))
  {
    for($cv=0;$cv<count($cnamearray);$cv++)
	{
	$val=$cnamearray[$cv];
	if($val=="School_Id")
	{
	$S_ID=$row[$val];
	}
	if($val=="Lab_Id")
	{
	$L_ID=$row[$val];
	}
	
		$th_cname= str_replace("_"," ",$val);
		if($val!="Last_Updated_Date")
	{
	       echo '<tr>';
        echo '<th width="200" height="29" scope="row" bgcolor="#3399CC">';
		echo $th_cname.":";
		echo '</th>';
        echo '<td width="144">';
		if($cv>8)
		{
	if($rownetwork=mysql_fetch_array($resultnetwork))
  {
  $Internet_Facilities=$rownetwork['Internet_Facilities'];  
$Availability_Of_LAN=$rownetwork['Availability_Of_LAN'];  
  $WAN_Connection_Type=$rownetwork['WAN_Connection_Type'];
    $Speed_Of_WAN=$rownetwork['Speed_Of_WAN'];
    $Supplied_Date=$rownetwork['Supplied_Date'];
    $Wired_Date=$rownetwork['Wired_Date'];
	$LAN_Supplier=$rownetwork['LAN_Supplier'];
	}
		if($th_cname=="Supplied Date")
		{
		if(isset($Supplied_Date))
		{
		echo "<input type='text' name='Supplied_Date' value='$Supplied_Date' class='inputDate1' id='inputDate1'>";
		}
		else
		{
		echo "<input type='text' name='Supplied_Date' value='$t_d' class='inputDate1' id='inputDate1'>";
		}
		}
		else if($th_cname=="Wired Date")
		{
		if(isset($Wired_Date))
		{
		echo "<input type='text' name='Wired_Date' value='$Wired_Date' class='inputDate2' id='inputDate2'>";
		}
		else
		{
		echo "<input type='text' name='Wired_Date' value='$t_d' class='inputDate2' id='inputDate2'>";
		}
		}
		else if($th_cname=="Speed Of WAN")
		{
			echo "<input type='text' name='Speed_Of_WAN' value='$Speed_Of_WAN'>";
		}
		else if($th_cname=="WAN Connection Type")
		{
			echo "<input type='text' name='WAN_Connection_Type' value='$WAN_Connection_Type'>";
		}
		else if($th_cname=="LAN Supplier")
		{
			echo "<input type='text' name='LAN_Supplier' value='$LAN_Supplier'>";
		}
		else if($th_cname=="Availability Of LAN")
		{
		if($Availability_Of_LAN=="Yes")
	  {
	    echo '<input type="radio" name="Availability_Of_LAN" value="Yes" id="Availability_Of_LAN_0" checked="checked" />';
	   echo "Yes";
	  }
	  else
	  {
		  echo '<input type="radio" name="Availability_Of_LAN" value="Yes" id="Availability_Of_LAN_0" />';
	   echo "Yes";
	  }
	  	 echo '<br />';
        if($Availability_Of_LAN=="No")
		{
          echo '<input type="radio" name="Availability_Of_LAN" value="No" id="Availability_Of_LAN_1" checked="checked" />';
          echo "No";
  }
  else
  {
	   echo '<input type="radio" name="Availability_Of_LAN" value="No" id="Availability_Of_LAN_1" />';
          echo "No";
  }
		}
		else if($th_cname=="Internet Facilities")
		{
		if($Internet_Facilities=="Yes")
	  {
	    echo '<input type="radio" name="Internet_Facilities" value="Yes" id="Internet_Facilities_0" checked="checked" />';
	   echo "Yes";
	  }
	  else
	  {
		  echo '<input type="radio" name="Internet_Facilities" value="Yes" id="Internet_Facilities_0" />';
	   echo "Yes";
	  }
	  	 echo '<br />';
        if($Internet_Facilities=="No")
		{
          echo '<input type="radio" name="Internet_Facilities" value="No" id="Internet_Facilities_1" checked="checked" />';
          echo "No";
  }
  else
  {
	   echo '<input type="radio" name="Internet_Facilities" value="No" id="Internet_Facilities_1" />';
          echo "No";
  }
		}
				}
		else
		{
		$valu=$row[$val];
		if($th_cname=="Date of commencement")
		{
		if($valu!=""&&$valu!="0000-00-00")
		{
		echo "<input type='text' name='Date_of_commencement' value='$valu' class='inputDate' id='inputDate'>";
		}
		else if($valu==""||$valu=="0000-00-00")
		{
		echo "<input type='text' name='Date_of_commencement' value='$t_d' class='inputDate' id='inputDate'>";
		}
		}
		else if($th_cname=="Special Project")
		{
$Special_Project=$row['Special_Project'];
$All_Special_Projects=="";
$OLPC="";
$Multimice="";
$IWB="";
$all_S_P=mysql_query("SELECT DISTINCT(Special_Project) FROM lab");
while($r_sp=mysql_fetch_array($all_S_P))
{
$sp_exists="";
$each_sp=explode(",",$r_sp['Special_Project']);
$All_SProjects=explode(",",$All_Special_Projects);
for($spr=0;$spr<count($each_sp);$spr++)
{
if($each_sp[$spr]!="")
{
if(substr($each_sp[$spr],0,6)=="other_")
{
$each_sp[$spr]=substr($each_sp[$spr],6);
}
if($each_sp[$spr]=="OLPC")
{
$OLPC="exists";
}
else if($each_sp[$spr]=="Multimice")
{
$Multimice="exists";
}
else if($each_sp[$spr]=="IWB")
{
$IWB="exists";
}

for($s=0;$s<count($All_SProjects);$s++)
{
if($each_sp[$spr]==$All_SProjects[$s])
{
$sp_exists="yes";
break;
}
}
if($sp_exists!="yes")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects=$each_sp[$spr];
}
else
{
$All_Special_Projects=$All_Special_Projects.",".$each_sp[$spr];
}
}
}
}
}
if($OLPC!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="OLPC";
}
else
{
$All_Special_Projects=$All_Special_Projects.",OLPC";
}
  }
  if($Multimice!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="Multimice";
}
else
{
$All_Special_Projects=$All_Special_Projects.",Multimice";
}
   }
   if($IWB!="exists")
{
if(empty($All_Special_Projects))
{
$All_Special_Projects="IWB";
}
else
{
$All_Special_Projects=$All_Special_Projects.",IWB";
}
   } 
$All_Spe_Projects=explode(",",$All_Special_Projects);
  $other="";

echo '<div style="width:180px; height:150px; overflow-Y:scroll; ">';
if($Special_Project!="")
{
$S_Proje= explode(",",$Special_Project);
for($s=0;$s<count($All_Spe_Projects);$s++)
{
$S_Proj="";
for($i=0;$i<count($S_Proje);$i++)
{
if($S_Proje[$i]==$All_Spe_Projects[$s])
{
$S_Proj="yes";
}
}
if($S_Proj=="yes")
{
echo "<input type='checkbox' name='Special_Projects[]' value='$All_Spe_Projects[$s]' checked='checked'/>";
  echo $All_Spe_Projects[$s];
    echo '<br/>';
  }
  else if($S_Proj=="")
  {
echo "<input type='checkbox' name='Special_Projects[]' value='$All_Spe_Projects[$s]'/>";
  echo $All_Spe_Projects[$s];
    echo '<br/>';
  }
else if(substr($All_Spe_Projects[$s],0,6)=="other_")
  {
  $other="exists";
    $sp=substr($All_Spe_Projects[$s],6);
	if($sp!="")
	{
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)' checked='checked'/>";
echo "Others";
  echo '<br/>';
  }
  else
  {
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)'/>";
echo "Others";
  echo '<br/>';
  }
?>
<textarea name='Special_Projects_Others'><?php echo $sp." "; ?></textarea>
<?php
}
}
if($other!="exists")
{
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)'/>";
echo "Others";
  echo '<br/>';
 ?>
<textarea name='Special_Projects_Others'></textarea>
<?php
}
}
else
{
for($sp=0;$sp<count($All_Spe_Projects);$sp++)
{
echo "<input type='checkbox' name='Special_Projects[]' value='$All_Spe_Projects[$sp]'/>";
echo "$All_Spe_Projects[$sp]";
echo '<br/>';
}
echo "<input type='checkbox' name='Special_Projects[]' value='Others(P1.specify)'/>";
echo "Others:";
  echo '<br/>';
echo "<textarea name='Special_Projects_Others'></textarea>";
}
		}
		else if($th_cname=="Lab Category")
		{
		echo '<select name="Lab_Category" id="Lab_Category">';
	  	  if(isset($valu))
	  {
	 echo '<option value="'.$valu.'">'.$valu.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  $lab=mysql_query("SELECT DISTINCT(Lab_Category) FROM lab");	  
  while($rowlc=mysql_fetch_array($lab))
  {  
  $L_Category=$rowlc['Lab_Category'];  	  
if($L_Category!=$valu)
{
	echo '<option value="'.$L_Category.'">'.$L_Category.'</option>';
}
}
   ?>
      </select><br/><label><font color="red">or</font> New lab category:</label>&nbsp;&nbsp;&nbsp;
	  <?php
	  if($New_Lab_Category!="")
	  {
	  echo "<input type='text' name='New_Lab_Category' value='$New_Lab_Category'/>";
	  }
	  else
	  {
	  echo "<input type='text' name='New_Lab_Category'/>";
	  }
		}
		else if($th_cname=="Lab Type")
		{
		echo '<select name="Lab_Type" id="Lab_Type">';
	    if(isset($valu))
	  {
	 echo '<option value="'.$valu.'">'.$valu.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  $lab=mysql_query("SELECT DISTINCT(Lab_Type) FROM lab");	  
  while($rowlt=mysql_fetch_array($lab))
  {  
  $L_Type=$rowlt['Lab_Type'];  	  
if($L_Type!=$valu)
{
	echo '<option value="'.$L_Type.'">'.$L_Type.'</option>';
}
}
   ?>
      </select><br/><label><font color="red">or</font> New lab type:</label>&nbsp;&nbsp;&nbsp;
	  <?php
	  if($New_Lab_Type!="")
	  {
	  echo "<input type='text' name='New_Lab_Type' value='$New_Lab_Type'/>";
	  }
	  else
	  {
	  echo "<input type='text' name='New_Lab_Type'/>";
	  }
		}
		else
		{
		echo "<input type='text' name='$val' value='$valu'>";
		}
		}
		echo '</td>';
      echo '</tr>';
	}
	}
}
	  echo '</table>';
	  echo '<br/>';
	   echo '<input name="Go" align="middle" type="submit" value="Go" class="gobutton"/>';	
	   }
	   ?>
</form>
	   <?php
	   if(isset($_POST['Go']))
	   {
	   $Lab_Type=$_POST['Lab_Type'];
$New_Lab_Type=$_POST['New_Lab_Type'];
$Lab_Category=$_POST['Lab_Category'];
$New_Lab_Category=$_POST['New_Lab_Category'];
$Special_Projects=$_POST['Special_Projects'];
$S_Pro="";
$S_Proje="";
	   $Lab_Type=$_POST['Lab_Type'];
$Lab_Id1=$_POST['Lab_Id'];
   $School_Id1=$_POST['School_Id'];
  $Source_Of_Power=$_POST['Source_Of_Power'];
    $Tp_Number=$_POST['Tp_Number'];
     $Account_Number=$_POST['Account_Number'];
    $Date_of_commencement=$_POST['Date_of_commencement'];
  $LAN_Supplier=$_POST['LAN_Supplier'];
   $Supplied_Date=$_POST['Supplied_Date'];
    $Speed_Of_WAN=$_POST['Speed_Of_WAN'];
     $WAN_Connection_Type=$_POST['WAN_Connection_Type'];
	 $Wired_Date=$_POST['Wired_Date'];
	  $Internet_Facilities=$_POST['Internet_Facilities'];  
$Availability_Of_LAN=$_POST['Availability_Of_LAN'];  
	date_default_timezone_set("Europe/Paris");
    $t_d=date("Y/m/d");
	for($i=0;$i<sizeof($Special_Projects);$i++)
  {
  if($i==0)
  {
   if($Special_Projects[$i]=="Others(P1.specify)")
  {
  $S_Proje="yes";
  $s_other=$_POST['Special_Projects_Others'];
   $spe_other=mysql_real_escape_string($s_other);
    if($spe_other=="")
  {
  $S_Pro="other_";
  $_SESSION['errorspo']="Please type the other special projects!";
  }
  else
  {
  $S_Pro="other_".$spe_other;
  }
  }
  else
  {
  $S_Pro=$Special_Projects[0];
  }
  }
   else
  {
    if($Special_Projects[$i]=="Others(P1.specify)")
  {
  $S_Proje="yes";
  $s_other=$_POST['Special_Projects_Others'];
   $spe_other=mysql_real_escape_string($s_other);
    if($spe_other=="")
  {
  $S_Pro=$S_Pro.",other_";
  $_SESSION['errorspo']="Please type the other special projects!";
  }
  else
  {
  $S_Pro=$S_Pro.",other_".$spe_other;
  }
  }
  else
  {
	$S_Pro=$S_Pro.",".$Special_Projects[$i];
	}
	}
	 }
if($New_Lab_Type!=""&&$Lab_Type!="Select One")
	{
$_SESSION['error']="Please select or type the lab's type!";
	}
	else if($New_Lab_Category!=""&&$Lab_Category!="Select One")
	{
$_SESSION['error']="Please select or type the lab's type!";
	}
	else
	{
	if($New_Lab_Type!="")
	{
	$Lab_Type=$New_Lab_Type;
	}
	if($New_Lab_Category!="")
	{
	$Lab_Category=$New_Lab_Category;
	}
	if($S_Proje=="yes")
  {
  $s_other=$_POST['Special_Projects_Others'];
   $spe_other=mysql_real_escape_string($s_other);
	  if($spe_other!="")
  {
	$sqln=mysql_query("UPDATE network SET Availability_Of_LAN='$Availability_Of_LAN',Internet_Facilities='$Internet_Facilities',School_Id='$School_Id1',Lab_Id='$Lab_Id1',Speed_Of_WAN='$Speed_Of_WAN',LAN_Supplier='$LAN_Supplier',Supplied_Date='$Supplied_Date',WAN_Connection_Type='$WAN_Connection_Type',Wired_Date='$Wired_Date',Last_Updated_Date='$t_d' WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
$up=mysql_query("UPDATE lab SET Lab_Category='$Lab_Category',Special_Project='$S_Pro',Lab_Type='$Lab_Type',School_Id='$School_Id1',Lab_Id='$Lab_Id1',Source_Of_Power='$Source_Of_Power',Tp_Number='$Tp_Number',Account_Number='$Account_Number',Date_of_commencement='$Date_of_commencement',Last_Updated_Date='$t_d' WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
	   if(!$up)
	   {
	   $_SESSION['up']="Sorry unable to edit this please try again!";
	   }
	   }
	   else
	   {
	   $_SESSION['up']="Please type the other special project!";
	   }
	   }
	   else
	   {
	   $sqln=mysql_query("UPDATE network SET Availability_Of_LAN='$Availability_Of_LAN',Internet_Facilities='$Internet_Facilities',School_Id='$School_Id1',Lab_Id='$Lab_Id1',Speed_Of_WAN='$Speed_Of_WAN',LAN_Supplier='$LAN_Supplier',Supplied_Date='$Supplied_Date',WAN_Connection_Type='$WAN_Connection_Type',Wired_Date='$Wired_Date',Last_Updated_Date='$t_d' WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
$up=mysql_query("UPDATE lab SET Lab_Category='$Lab_Category',Special_Project='$S_Pro',Lab_Type='$Lab_Type',School_Id='$School_Id1',Lab_Id='$Lab_Id1',Source_Of_Power='$Source_Of_Power',Tp_Number='$Tp_Number',Account_Number='$Account_Number',Date_of_commencement='$Date_of_commencement',Last_Updated_Date='$t_d' WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
	   if(!$up)
	   {
	   $_SESSION['up']="Sorry unable to edit this please try again!";
	   }
	   }
	   }
	if($_SESSION['Access_Type']=="Teacher"||$_SESSION['Access_Type']=="Teacher in Charge")
	{
	$T_NIC_Number=$_GET['T_NIC_Number'];
	$NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
    $result=mysql_query("SELECT * FROM lab WHERE School_Id='$Own_School_Id'");
	$Exc_que="SELECT * FROM lab WHERE School_Id='$Own_School_Id'";
   $number_of_rows=mysql_num_rows($result);
  }
  }
	else if($_SESSION['Access_Type']=="Administrator")
	{
	   $result=mysql_query("SELECT * FROM lab");
	$Exc_que="SELECT * FROM lab";
   $number_of_rows=mysql_num_rows($result);
	   }
if(mysql_num_rows($result)!=0)
   {
   $rnum=0;
   if(mysql_num_rows($result)>=10)
   {
	 echo '<div style="width:115%; height:410px; overflow-X:scroll; overflow-Y:scroll; ">';
	 }
	 else
	 {
	 echo '<div style="width:115%; overflow-X:scroll; ">';
	 }
  echo '<table width="1800" border="1" class="tablefontv">';
  	if($result)
  {
echo '<tr bgcolor="#6AB5FF">';
		if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
	{
echo '<td width="39"></td>
<td width="39"></td>';
}
$cnamearray=explode(',',$colnamearray);
    for($cv=0;$cv<count($cnamearray);$cv++)
	{
	$val=$cnamearray[$cv];
	if($val=="School_Id")
	{
	$S_ID=$row[$val];
	}
	if($val=="Lab_Id")
	{
	$L_ID=$row[$val];
	}
	  $th_cname= str_replace("_"," ",$val);
		
	$valu=$row[$val];
         echo '<td>';
		if($val=="School_Id")
  {
    $cnu=$cv+1;
	echo "(".$cnu.")School Name";
  }
  else
  {
	$cnu=$cv+1;
	echo "(".$cnu.")".$th_cname;
  }
		echo '</td>';
    }
		echo '<td>Column No</td>';
	echo '</tr>';
}

  while($row=mysql_fetch_array($result))
  {
	  $rnum=$rnum+1;  
$s=$row['School_Id'];
$l=$row['Lab_Id'];
$delVerification="delVerification".$rnum;
$name=$s.",".$l;
?>
<tr bgcolor="#999999">
<form action='#' method='post'>
<?php
   	if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
	{	
	?>
<td width="39">
<a href='?action=edit&School_Id=<?php echo $s; ?>&Lab_Id=<?php echo $l; ?>'><img src="../images/edit.png"/></a></td><td width="39"><?php echo "<input type='submit' id='$name' name='dele' onclick='DeleteVerification($rnum,this.id)' class='submitdelete' value=''/>";?></td>
	<?php 
	}
$cnamearray=explode(',',$colnamearray);
	for($cv=0;$cv<9;$cv++)
	{
	$val=$cnamearray[$cv];
	if($val=="School_Id")
	{
	$S_ID=$row[$val];
	}
	if($val=="Lab_Id")
	{
	$L_ID=$row[$val];
	}
	  $th_cname= str_replace("_"," ",$val);
		
	$valu=$row[$val];
		if($val=="School_Id")
{
$get_Sch_name=mysql_query("SELECT * FROM school WHERE School_Id='".$valu."'");
if($rs=mysql_fetch_array($get_Sch_name))
{
$Name=$rs['Name'];
}
echo '<td>';
		echo $Name;
		echo '</td>';
}
else
{
       echo '<td>';
		echo $valu;
		echo '</td>';
		}
  
	}
	$qucolnet="SHOW COLUMNS FROM network";
$resultcolnet=mysql_query($qucolnet);
$totcolnet=mysql_num_rows($resultcolnet);
$resultnet=mysql_query("SELECT * FROM network WHERE Lab_Id='$L_ID' AND School_Id='$S_ID'");
  if($rownet=mysql_fetch_array($resultnet))
  {
  while($rowcolunet=mysql_fetch_row($resultcolnet))
{
$column_Name_net=$rowcolunet[0];
if($column_Name_net!="Lab_Id"&&$column_Name_net!="School_Id")
{
    echo '<td>';
		echo $rownet[$column_Name_net];
		echo '</td>';
	 }
	 }
  }
  else
  {
  while($rowcolunet=mysql_fetch_row($resultcolnet))
{
$column_Name_net=$rowcolunet[0];
if($column_Name_net!="Lab_Id"&&$column_Name_net!="School_Id")
{
    echo '<td>';
		echo '';
		echo '</td>';
	 }
	 }
  }
	?>
	<td width="90">
    <?php
	 if($_SESSION['Access_Type']=="Teacher"||$_SESSION['Access_Type']=="Teacher in Charge")
	{
	   $resultte=mysql_query("SELECT * FROM lab WHERE School_Id='$Own_School_Id'");
	if($resultte)
  {
  if(mysql_num_rows($resultte)!=0)
  {
  $_SESSION['errornotallo']="Sorry you are not allowed to view all details!";
  }
  }
  $n=mysql_num_rows($resultte);
	}
	else if($_SESSION['Access_Type']=="Administrator")
	{
		$resultte=mysql_query("SELECT * FROM lab");
$n=mysql_num_rows($resultte);
	}
    echo "<div class='ctxt'><input type='text' size='5' name='$name' id='$groupcolumn'  onkeyup='GetCol(this.value,this.name,$rnum)' onclick='GetTBox($rnum,$n)'/></div>";
	$button="button".$rnum;
		echo "<div id='$button' class='sub_but'></div>";
	?></td>
    <?php
  echo '</tr>';
  }
  
   echo "</table></div>";
     $Column_names=explode(",",$_SESSION['Column_name']);
   if(count($Column_names)>0&&$_SESSION['Column_name']!="")
  {
   ?>
   <br/>
   <form action="#"/>
   <input type="submit" name="groupback" class="groupback" value=""/></form>
   <?php
   }
?>
</form>
<?php
}
	   }
	}
	}
		else
	{
	if(isset($_POST['groupback']))
  {
     $rnum=0;
	if($resultgro)
	 {	  
$qucol="SHOW COLUMNS FROM lab";
$resultcol=mysql_query($qucol);
$totcol=mysql_num_rows($resultcol);
while($rowcolu=mysql_fetch_row($resultcol))
{
if($rowcolu[0]!="Last_Updated_Date")
{
if(empty($colnamearray))
{
$colnamearray=$rowcolu[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolu[0];
}
}
}
$qucolnet="SHOW COLUMNS FROM network";
$resultcolnet=mysql_query($qucolnet);
$totcolnet=mysql_num_rows($resultcolnet);
while($rowcolunet=mysql_fetch_row($resultcolnet))
{
if($rowcolunet[0]!="School_Id"&&$rowcolunet[0]!="Lab_Id")
{
if(empty($colnamearray))
{
$colnamearray=$rowcolunet[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolunet[0];
}
}
}
if(mysql_num_rows($resultgro)>=10)
   {
	 echo '<div style="width:115%; height:410px; overflow-X:scroll; overflow-Y:scroll; ">';
	 }
	 else
	 {
	 echo '<div style="width:115%; overflow-X:scroll; ">';
	 }
  echo '<table width="1800" border="1" class="tablefontv">';
  echo '<tr bgcolor="#6AB5FF">';
		if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
	{
echo '<td width="39"></td>
<td width="39"></td>';
}
$cnamearray=explode(',',$colnamearray);
     for($cv=0;$cv<count($cnamearray);$cv++)
	{
	$val=$cnamearray[$cv];
	if($val=="School_Id")
	{
	$S_ID=$row[$val];
	}
	if($val=="Lab_Id")
	{
	$L_ID=$row[$val];
	}
	$th_cname= str_replace("_"," ",$val);
	$valu=$row[$val];
        echo '<td>';
		if($val=="School_Id")
  {
    $cnu=$cv+1;
	echo "(".$cnu.")School Name";
  }
  else
  {
	$cnu=$cv+1;
	echo "(".$cnu.")".$th_cname;
  }
		echo '</td>';
   
	}
	echo '<td>Column No</td>';
	echo '</tr>';
while($row=mysql_fetch_array($resultgro))
  {$rnum=$rnum+1;
    $s=$row['School_Id'];
$l=$row['Lab_Id'];
$delVerification="delVerification".$rnum;
$name=$s.",".$l;
?>
<tr bgcolor="#999999"><form action='#' method='post'>
<?php
   	if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
	{	
	?>
<td width="39">
<a href='?action=edit&School_Id=<?php echo $s; ?>&Lab_Id=<?php echo $l; ?>'><img src="../images/edit.png"/></a></td><td width="39"><?php echo "<input type='submit' id='$name' name='dele' onclick='DeleteVerification($rnum,this.id)' class='submitdelete' value=''/>";?></td>
	<?php 
	}
	$cnamearray=explode(',',$colnamearray);
	for($cv=0;$cv<9;$cv++)
	{
	$val=$cnamearray[$cv];
	if($val=="School_Id")
	{
	$S_ID=$row[$val];
	}
	if($val=="Lab_Id")
	{
	$L_ID=$row[$val];
	}
	  $th_cname= str_replace("_"," ",$val);
		
	$valu=$row[$val];
		if($val=="School_Id")
{
$get_Sch_name=mysql_query("SELECT * FROM school WHERE School_Id='".$valu."'");
if($rs=mysql_fetch_array($get_Sch_name))
{
$Name=$rs['Name'];
}
echo '<td>';
		echo $Name;
		echo '</td>';
}
else
{
        echo '<td>';
		echo $valu;
		echo '</td>';
		}
   
	}
	$qucolnet="SHOW COLUMNS FROM network";
$resultcolnet=mysql_query($qucolnet);
$totcolnet=mysql_num_rows($resultcolnet);
$resultnet=mysql_query("SELECT * FROM network WHERE Lab_Id='$L_ID' AND School_Id='$S_ID'");
  if($rownet=mysql_fetch_array($resultnet))
  {
  while($rowcolunet=mysql_fetch_row($resultcolnet))
{
$column_Name_net=$rowcolunet[0];
if($column_Name_net!="Lab_Id"&&$column_Name_net!="School_Id")
{
    echo '<td>';
		echo $rownet[$column_Name_net];
		echo '</td>';
	 }
	 }
  }
  else
  {
  while($rowcolunet=mysql_fetch_row($resultcolnet))
{
$column_Name_net=$rowcolunet[0];
if($column_Name_net!="Lab_Id"&&$column_Name_net!="School_Id")
{
    echo '<td>';
		echo '';
		echo '</td>';
	 }
	 }
  }
	?>
	<td width="90">
	<?php
	if($_SESSION['Access_Type']=="Administrator")
	{
		$resultte=mysql_query("SELECT * FROM lab");
	$n=mysql_num_rows($resultte);
	}
	 else if($_SESSION['Access_Type']=="Teacher"||$_SESSION['Access_Type']=="Teacher in Charge")
	{
	$NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
	   $resultte=mysql_query("SELECT * FROM lab WHERE School_Id='$Own_School_Id'");
	if($resultte)
  {
  if(mysql_num_rows($resultte)!=0)
  {
  $_SESSION['errornotallo']="Sorry you are not allowed to view all details!";
  }
  }
  $n=mysql_num_rows($resultte);
	}
	}
    echo "<div class='ctxt'><input type='text' size='5' name='$name' id='$groupcolumn'  onkeyup='GetCol(this.value,this.name,$rnum)' onclick='GetTBox($rnum,$n)'/></div>";
	$button="button".$rnum;
		echo "<div id='$button' class='sub_but'></div>";
	?></td>
    <?php
  echo '</tr>';
  }
  }
   echo "</table></div>";
   $Column_names=explode(",",$_SESSION['Column_name']);
   if(count($Column_names)>0&&$_SESSION['Column_name']!="")
  {
    ?>
   <br/>   
   <form action="#"/>
   <input type="submit" name="groupback" class="groupback" value=""/></form>
   <?php
   }
  ?>
  </form>
<?php  
   }
   if(!isset($_POST['groupback']))
  {
	  if($_SESSION['Access_Type']=="Administrator")
{
$result=mysql_query("SELECT * FROM lab");
	$Exc_que="SELECT * FROM lab";
   $number_of_rows=mysql_num_rows($result);
}
else if($_SESSION['Access_Type']=="Teacher"||$_SESSION['Access_Type']=="Teacher in Charge")
	{
	 $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
   $result=mysql_query("SELECT * FROM lab WHERE School_Id='$Own_School_Id'");
	$Exc_que="SELECT * FROM lab WHERE School_Id='$Own_School_Id'";
   $number_of_rows=mysql_num_rows($result);
   }
 }
if($result)
   {
   if(mysql_num_rows($result)==0)
   {
   $_SESSION['errornorow']="Sorry there is no result to view!";
   }
   if(mysql_num_rows($result)>0)
   {
     $rnum=0;
$qucol="SHOW COLUMNS FROM lab";
$resultcol=mysql_query($qucol);
$totcol=mysql_num_rows($resultcol);
while($rowcolu=mysql_fetch_row($resultcol))
{
if($rowcolu[0]!="Last_Updated_Date")
{
if(empty($colnamearray))
{
$colnamearray=$rowcolu[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolu[0];
}
}
}
$qucolnet="SHOW COLUMNS FROM network";
$resultcolnet=mysql_query($qucolnet);
$totcolnet=mysql_num_rows($resultcolnet);
while($rowcolunet=mysql_fetch_row($resultcolnet))
{
if($rowcolunet[0]!="School_Id"&&$rowcolunet[0]!="Lab_Id")
{
if(empty($colnamearray))
{
$colnamearray=$rowcolunet[0];
}
else
{
$colnamearray=$colnamearray.",".$rowcolunet[0];
}
}
}
 
 if($action!="group")
  {
  if(mysql_num_rows($result)>=10)
   {
	 echo '<div style="width:115%; height:410px; overflow-X:scroll; overflow-Y:scroll; ">';
	 }
	 else
	 {
	 echo '<div style="width:115%; overflow-X:scroll; ">';
	 }
   echo '<table width="2400" border="1" class="tablefontv">';
   	if($result)
  {
echo '<tr bgcolor="#6AB5FF">';
		if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
	{
echo '<td width="39"></td>
<td width="39"></td>';
}
$cnamearray=explode(',',$colnamearray);
     for($cv=0;$cv<count($cnamearray);$cv++)
	{
	 $val=$cnamearray[$cv];
	 if($val=="School_Id")
	{
	$S_ID=$row[$val];
	}
	if($val=="Lab_Id")
	{
	$L_ID=$row[$val];
	}
	  $th_cname= str_replace("_"," ",$val);
		
	$valu=$row[$val];
  echo '<td>';
	if($val=="School_Id")
  {
    $cnu=$cv+1;
	echo "(".$cnu.")School Name";
  }
  else
  {
	$cnu=$cv+1;
	echo "(".$cnu.")".$th_cname;
  }
		echo '</td>';
   
	}
	echo '<td>Column No</td>';
	echo '</tr>';
}
  while($row=mysql_fetch_array($result))
  {
	  $rnum=$rnum+1;
    
$s=$row['School_Id'];
$l=$row['Lab_Id'];
$delVerification="delVerification".$rnum;
$name=$s.",".$l;
?>
<tr bgcolor="#999999"><form action='#' method='post'>
<?php
   	if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
	{	
?>
<td width="39">
<a href='?action=edit&School_Id=<?php echo $s; ?>&Lab_Id=<?php echo $l; ?>'><img src="../images/edit.png"/></a></td>
<td width="39"><?php echo "<input type='submit' id='$name' name='dele' onclick='DeleteVerification($rnum,this.id)' class='submitdelete' value=''/>";?></td>
	<?php 
	}
	$cnamearray=explode(',',$colnamearray);
	for($cv=0;$cv<9;$cv++)
	{
	$val=$cnamearray[$cv];
	if($val=="School_Id")
	{
	$S_ID=$row[$val];
	}
	if($val=="Lab_Id")
	{
	$L_ID=$row[$val];
	}
	  $th_cname= str_replace("_"," ",$val);
		
		$valu=$row[$val];
			if($val=="School_Id")
{
$get_Sch_name=mysql_query("SELECT * FROM school WHERE School_Id='".$valu."'");
if($rs=mysql_fetch_array($get_Sch_name))
{
$Name=$rs['Name'];
}
echo '<td>';
		echo $Name;
		echo '</td>';
}
else
{
            echo '<td>';
		echo $valu;
		echo '</td>';
		}
    	}
		$qucolnet="SHOW COLUMNS FROM network";
$resultcolnet=mysql_query($qucolnet);
$totcolnet=mysql_num_rows($resultcolnet);
$resultnet=mysql_query("SELECT * FROM network WHERE Lab_Id='$L_ID' AND School_Id='$S_ID'");
  if($rownet=mysql_fetch_array($resultnet))
  {
  while($rowcolunet=mysql_fetch_row($resultcolnet))
{
$column_Name_net=$rowcolunet[0];
if($column_Name_net!="Lab_Id"&&$column_Name_net!="School_Id")
{
    echo '<td>';
		echo $rownet[$column_Name_net];
		echo '</td>';
	 }
	 }
  }
  else
  {
  while($rowcolunet=mysql_fetch_row($resultcolnet))
{
$column_Name_net=$rowcolunet[0];
if($column_Name_net!="Lab_Id"&&$column_Name_net!="School_Id")
{
    echo '<td>';
		echo '';
		echo '</td>';
	 }
	 }
  }
	?>
	<td><?php
	 if($_SESSION['Access_Type']=="Teacher"||$_SESSION['Access_Type']=="Teacher in Charge")
	{
	 $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
    	   $resultte=mysql_query("SELECT * FROM lab WHERE School_Id='$Own_School_Id'");
	$Exc_que="SELECT * FROM lab WHERE School_Id='$Own_School_Id'";
   $number_of_rows=mysql_num_rows($resultte);
		       if($resultte)
  {
  if(mysql_num_rows($resultte)!=0)
  {
  $_SESSION['errornotallo']="Sorry you are not allowed to view all details!";
  }
  }
  $n=mysql_num_rows($resultte);
	}
	}
	else if($_SESSION['Access_Type']=="Administrator")
	{
		$resultte=mysql_query("SELECT * FROM lab");
	$Exc_que="SELECT * FROM lab";
   $number_of_rows=mysql_num_rows($resultte);
  $n=mysql_num_rows($resultte);
	}
    echo "<div class='ctxt'><input type='text' size='5' name='$name' id='$groupcolumn'  onkeyup='GetCol(this.value,this.name,$rnum)' onclick='GetTBox($rnum,$n)'/></div>";
	$button="button".$rnum;
		echo "<div id='$button' class='sub_but'></div>";
	?></td>
   <?php
  echo '</tr>';
  }
  }
   if($action=="group")
  {
   $l_val=count($Column_names)-1;
  $gval=explode(",",$_SESSION['gvals']);
  $Column_names=explode(",",$_SESSION['Column_name']);
    $gval=explode(",",$_SESSION['gvals']);
  if($_SESSION['Access_Type']=="Administrator")
  {  
      $res_que="SELECT * FROM lab WHERE ";
	   $res_quenet="SELECT * FROM network WHERE ";
   for($j=0;$j<count($Column_names);$j++)
  {
  $Col_name=$Column_names[$j];
     $res_que=$res_que.$Col_name."='".$gval[$j]."'";
   if($j!=(count($Column_names)-1))
  {
  $res_que=$res_que." AND ";
  }
  }
	 $resultgro=mysql_query($res_que);
	$Exc_que=$res_que;
   $number_of_rows=mysql_num_rows($resultgro);
  }
 else if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
  {
   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
   }
      $res_que="SELECT * FROM lab WHERE ";
	   $res_quenet="SELECT * FROM network WHERE ";
   for($j=0;$j<count($Column_names);$j++)
  {
  $Col_name=$Column_names[$j];
   
  $res_que=$res_que.$Col_name."='".$gval[$j]."'";
  
  if($j!=(count($Column_names)-1))
  {
  $res_que=$res_que." AND ";
  }
  if($j==(count($Column_names)-1))
  {
  $res_que=$res_que." AND School_Id='".$Own_School_Id."'";
  }
  }
   $resultgro=mysql_query($res_que);
	$Exc_que=$res_que;
   $number_of_rows=mysql_num_rows($resultgro);
 }
 if(mysql_num_rows($resultgro)>=10)
   {
	 echo '<div style="width:115%; height:410px; overflow-Y:scroll; overflow-X:scroll;">';
 }
 else
  {
	 echo '<div style="width:115%; overflow-X:scroll;">';
 }
   echo '<table width="1800" border="1" class="tablefontv">';
 
   	if($gval[$l_val]!="")
  {
echo '<tr bgcolor="#6AB5FF">';
		if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
	{
echo '<td width="39"></td>
<td width="39"></td>';
}
$cnamearray=explode(',',$colnamearray);
     for($cv=0;$cv<count($cnamearray);$cv++)
	{
	 $val=$cnamearray[$cv];
	 if($val=="School_Id")
	{
	$S_ID=$row[$val];
	}
	if($val=="Lab_Id")
	{
	$L_ID=$row[$val];
	}
	  $th_cname= str_replace("_"," ",$val);
		
	$valu=$row[$val];
  echo '<td>';
	if($val=="School_Id")
  {
    $cnu=$cv+1;
	echo "(".$cnu.")School Name";
  }
  else
  {
	$cnu=$cv+1;
	echo "(".$cnu.")".$th_cname;
  }
		echo '</td>';
   
	}
	echo '<td>Column No</td>';
	echo '</tr>';
  $Column_names=explode(",",$_SESSION['Column_name']);
    $gval=explode(",",$_SESSION['gvals']);
	if($_SESSION['Column_name']!="")
  {  
 if($resultgro)
 {
   while($row=mysql_fetch_array($resultgro))
  {
  $rnum=$rnum+1;    
$s=$row['School_Id'];
$l=$row['Lab_Id'];
$delVerification="delVerification".$rnum;
$name=$s.",".$l;
?>
<tr bgcolor="#999999"><form action='#' method='post'>
<?php
   	if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
	{	
	?>
<td width="39">
<a href='?action=edit&School_Id=<?php echo $s; ?>&Lab_Id=<?php echo $l; ?>'><img src="../images/edit.png"/></a></td>
<td width="39"><?php echo "<input type='submit' id='$name' name='dele' onclick='DeleteVerification($rnum,this.id)' class='submitdelete' value=''/>";?></td>
	<?php 
	}
	$cnamearray=explode(',',$colnamearray);
	for($cv=0;$cv<9;$cv++)
	{
	$val=$cnamearray[$cv];
	if($val=="School_Id")
	{
	$S_ID=$row[$val];
	}
	if($val=="Lab_Id")
	{
	$L_ID=$row[$val];
	}
	  $th_cname= str_replace("_"," ",$val);
		$valu=$row[$val];
			if($val=="School_Id")
{
$get_Sch_name=mysql_query("SELECT * FROM school WHERE School_Id='".$valu."'");
if($rs=mysql_fetch_array($get_Sch_name))
{
$Name=$rs['Name'];
}
echo '<td>';
		echo $Name;
		echo '</td>';
}
else
{
        echo '<td>';
		echo $valu;
		echo '</td>';
		}
   
	}
$qucolnet="SHOW COLUMNS FROM network";
$resultcolnet=mysql_query($qucolnet);
$totcolnet=mysql_num_rows($resultcolnet);
$resultnet=mysql_query("SELECT * FROM network WHERE Lab_Id='$L_ID' AND School_Id='$S_ID'");
  if($rownet=mysql_fetch_array($resultnet))
  {
  while($rowcolunet=mysql_fetch_row($resultcolnet))
{
$column_Name_net=$rowcolunet[0];
if($column_Name_net!="Lab_Id"&&$column_Name_net!="School_Id")
{
    echo '<td>';
		echo $rownet[$column_Name_net];
		echo '</td>';
	 }
}
  }
 else
  {
  while($rowcolunet=mysql_fetch_row($resultcolnet))
{
$column_Name_net=$rowcolunet[0];
if($column_Name_net!="Lab_Id"&&$column_Name_net!="School_Id")
{
    echo '<td>';
		echo '';
		echo '</td>';
	 }
	 }
  }
	?>
	<td width="90">
	<?php
	 if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
	{
	$NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
	   $resultte=mysql_query("SELECT * FROM lab WHERE School_Id='$Own_School_Id'");
	if($resultte)
  {
  if(mysql_num_rows($resultte)!=0)
  {
  $_SESSION['errornotallo']="Sorry you are not allowed to view all details!";
  }
  }
  $n=mysql_num_rows($resultte);
	}
	}
	else if($_SESSION['Access_Type']=="Administrator")
	{
		$resultte=mysql_query("SELECT * FROM lab");
	$n=mysql_num_rows($resultte);
	}
    echo "<div class='ctxt'><input type='text' size='5' name='$name' id='$groupcolumn'  onkeyup='GetCol(this.value,this.name,$rnum)' onclick='GetTBox($rnum,$n)'/></div>";
	$button="button".$rnum;
		echo "<div id='$button' class='sub_but'></div>";
	?></td>
    <?php
  echo '</tr>';
  }
  }
  }
  }
  else
  {
echo '<tr bgcolor="#6AB5FF">';
		if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
	{
echo '<td width="39"></td>
<td width="39"></td>';
}
$cnamearray=explode(',',$colnamearray);
     for($cv=0;$cv<count($cnamearray);$cv++)
	{
	 $val=$cnamearray[$cv];
	 if($val=="School_Id")
	{
	$S_ID=$row[$val];
	}
	if($val=="Lab_Id")
	{
	$L_ID=$row[$val];
	}
	  $th_cname= str_replace("_"," ",$val);
		
	$valu=$row[$val];
  echo '<td>';
		if($val=="School_Id")
  {
    $cnu=$cv+1;
	echo "(".$cnu.")School Name";
  }
  else
  {
	$cnu=$cv+1;
	echo "(".$cnu.")".$th_cname;
  }
		echo '</td>';
   
	}
	echo '<td>Column No</td>';
	echo '</tr>';
  while($row=mysql_fetch_array($result))
  {
	  $rnum=$rnum+1;
    
$s=$row['School_Id'];
$l=$row['Lab_Id'];
$delVerification="delVerification".$rnum;
$name=$s.",".$l;
?>
<tr bgcolor="#999999"><form action='#' method='post'>
<?php
   	if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
	{	
	?>
<td width="39">
<a href='?action=edit&School_Id=<?php echo $s; ?>&Lab_Id=<?php echo $l; ?>'><img src="../images/edit.png"/></a></td>
<td width="39"><?php echo "<input type='submit' id='$name' name='dele' onclick='DeleteVerification($rnum,this.id)' class='submitdelete' value=''/>";?></td>
	<?php 
	}
	$cnamearray=explode(',',$colnamearray);
	for($cv=0;$cv<9;$cv++)
	{
	$val=$cnamearray[$cv];
	if($val=="School_Id")
	{
	$S_ID=$row[$val];
	}
	if($val=="Lab_Id")
	{
	$L_ID=$row[$val];
	}
	  $th_cname= str_replace("_"," ",$val);
		
		$valu=$row[$val];
			if($val=="School_Id")
{
$get_Sch_name=mysql_query("SELECT * FROM school WHERE School_Id='".$valu."'");
if($rs=mysql_fetch_array($get_Sch_name))
{
$Name=$rs['Name'];
}
echo '<td>';
		echo $Name;
		echo '</td>';
}
else
{
            echo '<td>';
		echo $valu;
		echo '</td>';
		}
    	}
		$qucolnet="SHOW COLUMNS FROM network";
$resultcolnet=mysql_query($qucolnet);
$totcolnet=mysql_num_rows($resultcolnet);
$resultnet=mysql_query("SELECT * FROM network WHERE Lab_Id='$L_ID' AND School_Id='$S_ID'");
  if($rownet=mysql_fetch_array($resultnet))
  {
  while($rowcolunet=mysql_fetch_row($resultcolnet))
{
$column_Name_net=$rowcolunet[0];
if($column_Name_net!="Lab_Id"&&$column_Name_net!="School_Id")
{
    echo '<td>';
		echo $rownet[$column_Name_net];
		echo '</td>';
	 }
	 }
  }
  else
  {
  while($rowcolunet=mysql_fetch_row($resultcolnet))
{
$column_Name_net=$rowcolunet[0];
if($column_Name_net!="Lab_Id"&&$column_Name_net!="School_Id")
{
    echo '<td>';
		echo '';
		echo '</td>';
	 }
	 }
  }
	?>
	<td><?php
	 if($_SESSION['Access_Type']=="Teacher"||$_SESSION['Access_Type']=="Teacher in Charge")
	{
	 $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
    	   $resultte=mysql_query("SELECT * FROM lab WHERE School_Id='$Own_School_Id'");
	if($resultte)
  {
  if(mysql_num_rows($resultte)!=0)
  {
  $_SESSION['errornotallo']="Sorry you are not allowed to view all details!";
  }
  }
  $n=mysql_num_rows($resultte);
	}
	}
	else
	{
		$resultte=mysql_query("SELECT * FROM lab");
	$n=mysql_num_rows($resultte);
	}
    echo "<div class='ctxt'><input type='text' size='5' name='$name' id='$groupcolumn'  onkeyup='GetCol(this.value,this.name,$rnum)' onclick='GetTBox($rnum,$n)'/></div>";
	$button="button".$rnum;
		echo "<div id='$button' class='sub_but'></div>";
	?></td>
   <?php
  echo '</tr>';
  }
  }
  }
   echo "</table></div>";
   $Column_names=explode(",",$_SESSION['Column_name']);
   if(count($Column_names)>0&&$_SESSION['Column_name']!="")
  {
   ?>
   <br/>
   <form action="#"/>
   <input type="submit" name="groupback" class="groupback" value=""/></form>
   <?php
   }
   ?>
   </form>
   <?php
   }
}
 else
	   {
	   $_SESSION['errornorow']="Sorry there is no result to view!";
	   }
	   }
  }
  if($_GET['action']!="edit"&&$action!="delete")
  {
   if($number_of_rows>0)
   {
$Exc_quer=str_replace("'","@",$Exc_que);
echo "<form action='../exportreport.php' method='post'><input type='submit' name='ToExcel' class='print' value=''/><input type='hidden' value='$Exc_quer' name='query'/><input type='hidden' value='lab' name='Exc_table_name'/></form>";
  }
  }
  ?>
<font class="err">
<?php
 if(isset($_SESSION['errornotallo']))
{
echo '<img src="../images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['errornotallo'];
unset($_SESSION['errornotallo']);
}
if(isset($_SESSION['errornorow']))
{
echo '<img src="../images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['errornorow'];
unset($_SESSION['errornorow']);
}
if(isset($_SESSION['value_empty']))
{
echo '<img src="../images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['value_empty'];
unset($_SESSION['value_empty']);
}	
if($action=="delete")
{
	if(isset($_SESSION['del']))
{
echo '<img src="../images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['del'];
unset($_SESSION['del']);
}
	if(isset($_SESSION['errornet']))
{
echo $_SESSION['errornet'];
unset($_SESSION['errornet']);
}
}
if(isset($_SESSION['groupbyempty']))
{
echo '<img src="../images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['groupbyempty'];
unset($_SESSION['groupbyempty']);
}
if(isset($_POST['Go']))
{
	if(isset($_SESSION['up']))
{
echo '<img src="../images/alert.jpg" width="12" height="12"/>';
echo $_SESSION['up'];
unset($_SESSION['up']);
}
}
	?>
	</font>
	  </div>
  </div>
</div>
<div id="sidebar">
<br/>
<div id="partners" class="boxed">
			<h2 class="title">LABS</h2>
            </div>
            <?php
include_once "menu.php";
?>
 <?php
include_once "../footer.php";
}
?>

</body>
</html>